<?php
//App::import('Vendor','tcpdf/tcpdf');
App::import('Vendor','xtcpdf');
$tcpdf = new XTCPDF();
//$tcpdf = new XTCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$textfont = 'helvetica';
 
//$tcpdf->SetAuthor("bachpt");
//$tcpdf->SetAutoPageBreak(true);

$tcpdf->setHeaderFont(array($textfont,'',20)); 
$tcpdf->xheadercolor = array(150,0,0); 
$tcpdf->xheadertext = 'Schools'; 
$tcpdf->xfootertext = 'Beaconschool. All rights reserved.'; 
 
$tcpdf->setPrintHeader(true);
$tcpdf->setPrintFooter(true);

// set default monospaced font
$tcpdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins
$tcpdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$tcpdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$tcpdf->SetFooterMargin(PDF_MARGIN_FOOTER);

//set auto page breaks
$tcpdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

//set image scale factor
$tcpdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

$tcpdf->SetTextColor(0, 0, 0);
$tcpdf->SetFont($textfont,'',7);
 
$tcpdf->AddPage();


 
// create some HTML content

foreach ($schools as $school) {
$htmlcontent = <<<EOD
	<table border="0" style="width: 100%">
		<tr>
			<td colspan="2" style="font-size: 10pt; width: 40%" >
				<b>{$school['School']['schoolName']}</b>
			</td>
			<td style="width: 20%">
				<b>Contact</b> {$school['Contact']['contactName']}
			</td>
			<td colspan="3" style="width: 40%">
				<b>Sponsor by</b> {$school['Sponsor']['sponsorName']}
			</td>
		</tr>
		<tr>
			<td style="width: 10%">
				<b>Username</b>
			</td>
			<td style="width: 30%">
				{$school['User']['userName']}
			</td>
			<td style="width: 20%">
				{$phone->format_phone($school['Contact']['phone'])}
			</td>
			<td style="width: 10%">
			</td>
			<td style="width: 15%">
				{$school['Contact']['address1']}
			</td>
			<td style="width: 15%">
			</td>
		</tr>
		<tr>
			<td style="width: 10%">
				<b>User Status</b>
			</td>
			<td style="width: 30%">
				{$school['User']['active']}
			</td>
			<td style="width: 20%">
				{$school['Contact']['email']}
			</td>
			<td colspan="3" style="width: 40%">
			</td>
		</tr>
		<tr>
			<td style="width: 10%">
				<b>Default SMSC</b>
			</td>
			<td style="width: 30%">
			</td>
			<td style="width: 20%">
			</td>
			<td style="width: 10%">
			</td>
			<td style="width: 15%">
				{$school['Contact']['address1']}
			</td>
			<td style="width: 15%">
			</td>
		</tr>
		<tr>
			<td style="width: 10%">
				<b>Notes</b>
			</td>
			<td colspan="4" style="width: 75%">
				<table border="1">
					<tr>
						<td>&nbsp;</td>
					</tr>
				</table>
			</td>
			<td style="width: 15%">
				<table border="0" style="width:100%; font-size: 7pt; vertical-align: bottom">
					<tr>
						<td>
							School ID
						</td>
						<td align="right">
							{$school['School']['id']}
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
EOD;
// output the HTML content
$tcpdf->writeHTML($htmlcontent, true, 0, true, 0);
$tcpdf->Cell(0, 0, '' ,'T', 1, 'L');
}

$tcpdf->Output('schools.pdf', 'D');
?>
